package common

const CheckTableJsonPath string = "/static/js/checktable_data.json"

const (
	SERVER_NORMAL int32 = iota
	SERVER_BUSY
	SERVER_OFFLINE

	SERVER_END
	SERVER_COUNT = SERVER_END - 1
)

const (
	AREA_NORMAL = 0 //正常
	AREA_NEW    = 1 //新区
)
const (
	ALIAS_WEBADMIN   string = "default"
	ALIAS_DATAREPORT string = "data_report"
)

const (
	CMD_LOGIN         string = "login"
	CMD_WEBSERVER_CFG string = "webservercfg"
	CMD_WEBUSER_CFG   string = "webusercfg"
	CMD_ECHART        string = "echart"
	CMD_ANNOUNCE      string = "announce"
)

//游服上报服务器在线消息
type OnlineUserReport struct {
	ServerName    string `form:"serverName" json:"serverName" binding:"required"`       //服务器名字
	TimeStamp     int64  `form:"timeStamp" json:"timeStamp" binding:"required"`         //接收到的游服时间戳
	Cycle         uint32 `form:"cycle" json:"cycle" binding:"required"`                 //发送周期
	LoginNums     uint32 `form:"loginNums" json:"loginNums" binding:"required"`         //每个周期上线人数
	OfflineNums   uint32 `form:"offlineNums" json:"offlineNums" binding:"required"`     //每个周期下线人数
	OnlineNums    uint32 `form:"onlineNums" json:"onlineNums" binding:"required"`       //当前在线人数
	MaxOnLineNums uint32 `form:"maxOnLineNums" json:"maxOnLineNums" binding:"required"` //最大在线人数
}

//游服上报系统信息
type SysReportInfo struct {
	ServerName  string `json:"serverName"`  //服务器名字
	TotalMem    uint64 `json:"totalmem"`    //游服总内存，单位Bytes
	Samplecycle uint32 `json:"samplecycle"` //采样周期，单位秒
	Sendcycle   uint32 `json:"sendcycle"`   //发送周期，单位秒
	TimeStamp   int64  `json:"timeStamp"`   //发送时间戳

	CpuUsage     []float64 `json:"cpuUsage"`     //一个发送周期的所有cpu使用率
	MemSysUsage  []uint64  `json:"memSysUsage"`  //一个发送周期的系统mem占用Bytes
	MemProgUsage []uint64  `json:"memProgUsage"` //一个发送周期的程序mem占用Bytes
}

type Serverinfo struct {
	ServerName    string `json:"serverName"`    //服务器名字
	OnlineNums    uint32 `json:"onlineNums"`    //当前在线人数
	MaxOnLineNums uint32 `json:"maxOnLineNums"` //每个周期最大在线人数
}

const (
	ACCESS_ADMIN  int32 = 1 //root权限
	ACCESS_SERVER int32 = 2 //只有修改查看serverCfg的权限
	ACCESS_REPORT int32 = 3 //查看chart报告权限
)

//web服务器发送给客户端消息
type ServerListS2C struct {
	ServerList []Serverinfo `json:"serverlist"`
}

//web服务器发送给浏览器server数据
type S2WServerData struct {
	Id        int    `json:"id"`
	Ip        string `json:"ip"`
	Name      string `json:"name"`
	Area      string `json:"area"`
	Port      int    `json:"port"`
	NewServer int    `json:"newServer"`
	ChanId    string `json:"chan_id"`
}

//web服务器发送给浏览器user数据
type S2WUserData struct {
	Name   string `json:"name"`
	Ip     string `json:"ip"`
	Passwd string `json:"passwd"`
	Access int    `json:"access"`
	Other  string `json:"other"`
}

type C2SJson struct {
	StartTime  string `"startTime"`
	EndTime    string `"endTime"`
	SelType    int32  `"selType"`
	ServerName string `"serverName"`
}

type AnnounceText struct {
	Announce string `"announce"`
	SendTime string `"sendtime"` //发送时间戳
}

const (
	SEL_SEC  int32 = 1 //按秒钟
	SEL_MIN  int32 = 2 //按分钟
	SEL_HOUR int32 = 3 //按小时
)

var DebugCtrl int32 = 1

const TimeModel string = "2006-01-02 15:04:05"

var GStopFlag bool = false
